__author__ = 'tomoya'

class HtmlOutputer(object):

    def __init__(self):
        self.datas = []

    def collect_data(self, data):
        if data is None:
            return
        self.datas.append(data)

    def output_html(self):
        fout = open('output.html', 'w')

        fout.write('<html>')
        fout.write('<head><meta charset="utf-8"/>')
        fout.write('<link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">')
        fout.write('</head>')
        fout.write('<body>')
        fout.write('<div class="container">')
        fout.write('<table class="table table-bordered">')
        for data in self.datas:
            fout.write('<tr>')
            fout.write('<td>%s</td>' % data['url'])
            fout.write('<td>%s</td>' % data['title'].encode('utf-8'))
            fout.write('<td>%s</td>' % data['content'].encode('utf-8'))
            fout.write('</tr>')
        fout.write('</table>')
        fout.write('</div>')
        fout.write('</body>')
        fout.write('</html>')